package com.heima.apis.article;

import com.heima.model.article.dtos.ArticleDto;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.common.enums.AppHttpCodeEnum;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

@FeignClient(value = "leadnews-article",fallback = IArticleClient.IArticleClientFallback.class)
public interface IArticleClient {

    @PostMapping("/api/v1/article/save")
    public ResponseResult saveArticle(@RequestBody ArticleDto dto);

    /**
     * feign失败配置
     * @author itheima
     */
    @Component
    public class IArticleClientFallback implements IArticleClient {
        @Override
        public ResponseResult saveArticle(ArticleDto dto)  {
            return ResponseResult.errorResult(AppHttpCodeEnum.SERVER_ERROR,"获取数据失败");
        }
    }
}
